﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace Pavilion
{
    public class GameController
    {
        private List<ContainerNodeMonitor> containerNodeMonitorCollection;

        public GameController()
        {
            containerNodeMonitorCollection = new List<ContainerNodeMonitor>();
        }

        public void LoadGame()
        {
            UnloadGame();

            GameData gameData = new GameData() { GameItemName = "RootGameItem", GameToolName = "NodeTool" };
            gameData.PropertyDictionary.Add("ResourceName", GameEngine.MainScript);

            GameItem gameItem = GameItemManager.Instance.CreateGameItem(gameData.GameItemName);

            gameData.UpdateGameData(gameItem);
        }

        public void UnloadGame()
        {
            GameItemManager.Instance.UnloadAllGameItems();
            ResourceManager.Instance.UnloadContent();
            CollisionManager.Instance.Clear();
            DrawManager.Instance.Clear();
        }

        public void Update(GameTime gameTime)
        {
            CollisionManager.Instance.Update();

            foreach (GameItem gameItem in GameItemManager.Instance.GameItemCollection)
                gameItem.Update(gameTime);
        }

        public void Draw()
        {
            DrawManager.Instance.Draw();
        }
    }
}
